#include "rightformitem.h"
#include "qdebug.h"
#include "ui_rightformitem.h"

rightFormitem::rightFormitem(bool isLike, QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::rightFormitem)
    , isLike(isLike)
{
    ui->setupUi(this);

    if(isLike)
        ui->pushButton->setStyleSheet("border: none;border-image:url(:/pic/liking.png);");
    else
        ui->pushButton->setStyleSheet("border: none;border-image:url(:/pic/like.png);");

    connect(ui->pushButton, &QPushButton::clicked, this, &rightFormitem::toggleLikeState);
}

rightFormitem::~rightFormitem()
{
    delete ui;
}

void rightFormitem::enterEvent(QEvent *event)
{
    (void)event;
    this->setStyleSheet("background-color:rgba(170, 170, 170, 25);");
}

void rightFormitem::leaveEvent(QEvent *event)
{
    (void)event;
    this->setStyleSheet("");
}

void rightFormitem::setNameitem(const QString name)
{
    ui->label->setText(name);
}

void rightFormitem::setAuthoritem(const QString author)
{
    ui->label_2->setText(author);
}

void rightFormitem::setAlbumitem(const QString album)
{
    ui->label_3->setText(album);
}

void rightFormitem::toggleLikeState()
{
    isLike = !isLike;
    emit setisLike(isLike);
}
